class Solution {
public:
    void rotate(vector<vector<int>>& matrix) {
        int n = matrix.size();
        int up = 0,down = n-1;
        while(up < down) //水平镜像
        {
            for(int i = 0;i < n;++i)
            {
                std::swap(matrix[up][i],matrix[down][i]);
            }
            ++up,--down;
        }
        int index = 0; //对角线镜像
        while(index < n)
        {
            for(int i = index;i < n;++i){
                std::swap(matrix[i][index],matrix[index][i]);
            }
            ++index;
        }
    }
};